const ImagesToGifConverter = require('../utils/ImagesToGif');

const imagesToGifFn = async (event, config, defaultFfmpegPath, mainWindow) => {
  try {
    // 创建GIF转换器实例
    const converter = new ImagesToGifConverter(config);
    
    // 配置FFmpeg路径
    if (config.ffmpegPath) {
      converter.configureFfmpeg(config.ffmpegPath);
    } else {
      converter.configureFfmpeg(defaultFfmpegPath);
    }
    
    // 执行转换
    const result = await converter.convertToGif(mainWindow);
    return result;
  } catch (error) {
    console.error('图片转GIF失败:', error);
    throw error;
  }
};

module.exports = {
  imagesToGifFn
};
